﻿using System;
using System.Collections.Generic;
using System.Linq;
using Dqaqs.Common;

namespace Algorithms.Common.Data
{
    public static class CsvHelper
    {
        public static IEnumerable<string[]> BasicCsvToArray(IEnumerable<string> lines)
        {
            ArgumentCheck.NotNull(lines, "lines");
            return lines.Select(l => l.Split(",".ToCharArray()).ToArray());
        }

        public static IEnumerable<string[]> BasicCsvToArray(string txt)
        {
            ArgumentCheck.NotNullOrEmpty(txt, "txt");
            return BasicCsvToArray(txt.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
        }
    }
}
